
let a = document.querySelector('a')
a.addEventListener('click', function () {
    location.href = './register.html'
})
require('../css/login.css');
require('../fonts/iconfont.css');
require('../css/reset.css')


let btn = document.querySelector('.btn')
let user = document.querySelector('.user input')
let paw = document.querySelector('.password input')
btn.addEventListener('click', function () {
    if (!(user.value && paw.value)) {
        // alert('输入框不能为空')
        common.toast('输入框不能为空', false);
        return
    }
    axios.post('/api/user/login', {
        account: user.value,
        password: paw.value
    }).then(function (res) {
        if (res.data.errno == 0) {
            // alert('登录成功');
            common.toast('登录成功', true);

            sessionStorage.setItem('token', res.data.data.token)
            location.href = './index.html'
        } else {
            // alert(res.data.message)
            common.toast(res.data.message, false);

        }
    })
})

